package com.thiswhyme.sentinel.server2.handler;

import com.thiswhyme.common.response.ResponseVo;

/**
 * @description: fallback处理，参数需要和源方法参数一致，可多加一个Throwable
 * @author: thiswhyme
 * @date: 2020/9/3
 */
public class BizFallbackHandler {

    /**
     * defaultFallback方法无参或仅带一个Throwable参数
     * @param e
     * @return
     */
    public static ResponseVo<String> defaultFallbackHandle(Throwable e) {
        return ResponseVo.failure("406", "默认Fallback处理");
    }

    /**
     * fallback方法参数需要和源方法参数一致，可多加一个Throwable
     * @param userId
     * @param e
     * @return
     */
    public static ResponseVo<String> queryUserName2FallbackHandle(Integer userId, Throwable e) {
        return ResponseVo.failure("406", String.format("queryUserName2业务Fallback处理, userId: %s, errMsg: %s", userId, e.getMessage()));
    }
}
